{extend name="/fool" /}
{block name="css"}
<style>
	#page{
        position: relative;
        display: inline-block;
        left:30%;
        margin-left:-50px;
        padding:50px 0;
    }
    #one{
    	margin: 30px 50px;
	}
	.layui-input{
	    width:200px;
	    border-radius: 5px;
	    margin:5px 10px;
	}
	.layui-form-select .layui-edge{
	    right:20px;
	}
	table{
	    margin:0 5vw;
	}
	table th{
	    width:25vw;
	}
	.last{
	    width:15vw;
	}
	table td{
	    text-align: center;
	    padding:15px 0
	}
	.list{
	    border-bottom:1px solid rgba(0,0,0,0.3);
	}
</style>
{/block}
{block name="menu_content"}
<div id="one">
    <form class="layui-form" action="" method="post">
        <ul>
            <li>
                <div class="layui-input-inline">
                    <input type="text" name="name" autocomplete="off" class="layui-input" placeholder="服务中心名称">
                </div>
                <div class="layui-input-inline">
                    <select name="status">
                        <option value="">状态</option>
                        <option value="1">开启</option>
                        <option value="2">关闭</option>
                    </select>
                </div>
                <button type="Submit" class="layui-btn">筛选</button>
                {if $login['admin'] > 2}
                <button type="button" class="add layui-btn">添加</button>
                {/if}
            </li>
        </ul>
    </form>
</div>
<div>
    <table>
        <tr>
            <th>id</th>
            <th>服务中心名称</th>
            <th>机台数量</th>
            <th>运行状态</th>
            <th class="last">操作</th>
        </tr>
        {if isset($list)}
        {foreach $list as $v}
        <tr class="list">
            <td>{$v.id}</td>
            <td>{$v.name}</td>
            <td>{$v.num}</td>
            <td>
                {if $v.status == 1}
                运行中
                {elseif $v.status ==2}
                <span style="color:#f00;">停运</span>
                {/if}
            </td>
            <td>
                <button sid="{$v.id}" type="button" class="jt layui-btn layui-bg-blue">机台</button>
                <button sid="{$v.id}" type="button" class="upload layui-btn">编辑</button>
            </td>
        </tr>
        {/foreach}
        {/if}
    </table>
    <div id="page">
    </div>
</div>
<script>
    $(".add").click(function(){
        location.href = "{:url('add')}"
    })
    $(".jt").click(function(){
        var id = $(this).attr('sid');
        location.href = "{:url('indexs')}" + '?id=' + id;
    })
    $(".upload").click(function(){
        var id = $(this).attr('sid');
        location.href = "{:url('upload')}" + '?id=' + id;
    })
    layui.use('form', function(){
        var form = layui.form;

        //监听提交
        form.on('submit(formDemo)', function(data){
            layer.msg(JSON.stringify(data.field));
            return false;
        });
    });
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#test1'
            ,type: 'month'
            ,range: '至'
            ,format: 'yyyy-MM'
        });
    });
    layui.use('laypage', function(){
        var laypage = layui.laypage;
        //执行一个laypage实例
        laypage.render({
            elem: 'page'
            ,count: "{$count}"
            ,curr:"{$curl}"
            ,last:"{$groups}"
            ,limit:"{$limit}"
            ,layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
            ,jump: function(obj,first){
                console.log(obj)
                if(!first){
                    var url = "{:url('index',['id'=>5,'index'=>0])}" + '&page=' + obj.curr + '&limit=' + obj.limit + '&curr=' + obj.curr;
                    location.href = url;
                }
            }
        });
    });
</script>
{/block}